/**
 * 分类列表-数组提取扁平化缓存数据函数
 * @param {*} arr
 * @param {*} name
 */
export const arrToCacheData = (arr, name) => {
  let cacheData = {};
  for (let i = 0; i < arr.length; i++) {
    const ele = arr[i];
    const childs = [{ ID: 0, Name: '全部' }].concat(arr[i][name]);
    cacheData[ele.ID] = childs;
  }
  return cacheData;
};

/**
 * 分类列表-数组提取当前考试方向所有学科
 * @param {*} arr
 * @param {*} name
 */
export const arrToSubject = (arr) => {
  let subjectData = {};

  return subjectData;
};
export const shakeTreeArr = function (arr, childField) {
  arr?.map((item) => {
    if (item[childField]?.length) {
      item[childField] = shakeTreeArr(item[childField], childField);
    } else {
      item[childField] = undefined;
    }
  });
  return arr;
};
